<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
	"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
	<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
	<title>FlashLoader Load Single Item Example</title>
	<script src="js/jquery-1.5.2.min.js" type="text/javascript"></script>
	<script src="js/swfobject.js" type="text/javascript"></script>
	<script src="js/flashLoader.js" type="text/javascript"></script>
	<script type="text/javascript">
		// Initialize FlashLoader JavaScript helper utility
		FlashLoader.init({
			debug: true, // enables debugging output. Optional. Default is false.
			debugMode: 'console', // sets debug output mode. Optional. Use 'console' for console.log() or 'alert' for alert(). Default is 'console'.
			onReady: onFlashLoaderReady // pass a reference to a function to call once the FlashLoader swf is ready to use
		});
		
		// function called when FlashLoader is ready to use. Initialize application here.
		function onFlashLoaderReady()
		{
			$('#load-html').click(function(e){
				FlashLoader.load('data/example.html', 'onHTMLLoad');
			});
			
			$('#load-js').click(function(e){
				FlashLoader.load('data/example.js', 'onJSLoad');
			});
			
			$('#load-json').click(function(e){
				FlashLoader.load('data/example.json', 'onJSONLoad');
			});
			
			$('#load-txt').click(function(e){
				FlashLoader.load('data/example.txt', 'onTXTLoad');
			});
			
			$('#load-xml').click(function(e){
				FlashLoader.load('data/example.xml', 'onXMLLoad');
			});
			
			$('#clear-output').click(function(e){
				$('#output').html('');
			});
		}
		
		// Data is returned as a string which can be directly added to the DOM.
		function onHTMLLoad(data)
		{
			$('#output').append('<p>HTML data:</p>');
			$('#output').append(data);
		}
		
		// Data is returned as a string which can be evaluated as JavaScript
		function onJSLoad(data)
		{
			$('#output').append('<p>JS data:</p>');
			$('#output').append(data);
			
			// evaluate JavaScript
			// eval(data);
			
		}
		
		// Data is returned as a string which can be parsed as a JSON object
		function onJSONLoad(data)
		{
			$('#output').append('<p>JSON data:</p>');
			$('#output').append(data);
			
			// convert to JSON object:
			// var obj = $.parseJSON(data);
		}
		
		// Data is returned as a string.
		function onTXTLoad(data)
		{
			$('#output').append('<p>TXT data:</p>');
			$('#output').append(data);
		}
		
		// Data is returned as a string which can be parsed as XML
		function onXMLLoad(data)
		{
			$('#output').append('<p>XML data:</p>');
			$('#output').append(data);
			
			// wrap in jquery object to allow DOM manipulation
			// $(data)
		}
		
		// Embed FlashLoader swf (flashLoader.swf) when the DOM has loaded.
		$(function(){
			var flashVars = {};
			var params = {};
			var attributes = {
				id: "FlashLoader"
			};
				
			swfobject.embedSWF("flashLoader.swf", "FlashLoader", "0", "0", "10.0.0", "expressInstall.swf", flashVars, params, attributes);
		});
		
		
	</script>
</head>
<body>
	<h2>FlashLoader</h2>
	<h3>Load single file example.</h3>
	<p>FlashLoader is a Flash and JavaScript method of providing AJAX functionality when a browser's local security restrictions prevent the use of AJAX. This example demonstrates loading files individually. Click the buttons below to load a file and display its output.</p>

	<button id="load-html">Load HTML</button>
	<button id="load-js">Load JS</button>
	<button id="load-json">Load JSON</button>
	<button id="load-txt">Load TXT</button>
	<button id="load-xml">Load XML</button>
	<button id="clear-output">Clear Output</button>
	<h3>Output</h3>
	<div id="output"></div>
	<!-- FlashLoader swf is embedded here -->
	<div id="FlashLoader">
		<h1>Please install Flash Player</h1>
		<p>Flash Player must be installed to use FlashLoader</p>
		<p><a href="http://www.adobe.com/go/getflashplayer"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" /></a></p>
	</div>
</body>
</html>